package com.xueshan.disruptor.lmax.consumer;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

import com.xueshan.disruptor.lmax.event.ObjectEvent;
import lombok.extern.slf4j.Slf4j;


/**
 * created with IDEA
 *
 * @author:huqm
 * @date:2021/3/16
 * @time:17:18 <p>
 *
 * </p>
 */
@Slf4j
public abstract class DisruptorConsumer<T> implements EventHandler<ObjectEvent<T>>, WorkHandler<ObjectEvent<T>>{

    public void onEvent(ObjectEvent<T> event, long sequence, boolean endOfBatch) throws Exception {
        if(sequence==1024*1024-1){
            log.info("完成时间{}",System.currentTimeMillis());
        }
        this.onEvent(event);
    }

    public void onEvent(ObjectEvent<T> event) throws Exception {
        this.consume(event.getObj());
    }


    public abstract void consume(T var1);

}
